
*------------------------------------------------------------------------------*
* Government position weighted by seat share of coalition parties
*
* Additional specs:
*	1. Excluding NONAs and parties with missing ideology
*	2. Fallback: 1st chamber median for expert governments
*
* Version:	2016-06-10
* Changes:	2016-??-??: First release
*------------------------------------------------------------------------------*


* Exclude NONAs and parties with missing ideology
gen filterseat = p303 if p103 == 1 & $ideology != .
by g101 g105, sort: egen newsumseat=sum(filterseat)
gen newpofseat = (filterseat / newsumseat * 100)

* Weigh new p% of cabinet seats with ideology
gen zs1 = ($ideology * newpofseat) / 100

* Aggregate
by g101 g105, sort: egen GOV_POS = sum(zs1)
save zs, replace


* Fill in GOV_POS with fallback
replace GOV_POS = median1st if newsumseat == 0 & GOV_POS == 0


* Cleansing
replace GOV_POS = . if g106 == 9

lab var GOV_POS "Position of government"

sort g101 g105 p101

capture: drop zs* filterseat newsumseat newpofseat 
capture: erase zs.dta
capture: erase zs_median.dta
